$(function(){
	$(':input').labelauty()	
	//Txt文本导入
	$("#importTxt").click(function () {
        $("#numberFile").click();
    });
	
	$("#fileForm").ajaxForm({
        success: function (data) {
            $("#mobilenumbers").val(data);
        },
        error: function (XmlHttpRequest, textStatus, errorThrown) {
            alert("操作失败:服务器错误");
        }
    });
	
	//过滤错号
	$("#checkMobile").click(function () {
		$("#pkg").empty();
		var numberMeg = $("#mobilenumbers").val();
		var type= '2';
     		$.ajax({
     			type : "post",
     			url:basePath+"batchCheckPhone",
     			data:{numberMeg:numberMeg,type:type},
     			success:function(data){
     				if (data != "" && data != null) {
     					$("#terminalName").val(data.agentName);
     					$("#mobilenumbers").val(data.phoneMeg);
     					var count = data.count;
     					var valid = data.valid;
     					var inValid = data.inValid;
     					countNum(count,valid,inValid);
     					var meg=$("#meg");
     					var dt=data.ThreeNet;
     					var dt2=data.VirtualNet
     					
     					for(var key in dt2)
         				{
     						var pkgData=dt2[key];
     						var li='<li>'+pkgData+'</li>'
     						var ul='<ul class="dowebok">'+li+'</ul>';
     	           			var div2='<div class="col-sm-8">'+ul+'</div>';
     	     				var label='<label class="col-sm-2 control-label">'+key+'</label>';
     	         			var div='<div class="form-group ">'+label+div2+'</div>';	
     	         			meg.append(div);
         				}
     					for(var key in dt)
         				{
     						var pkgData=dt[key];
     						var li='<li>'+pkgData+'</li>'
     						var ul='<ul class="dowebok">'+li+'</ul>';
     	           			var div2='<div class="col-sm-8">'+ul+'</div>';
     	     				var label='<label class="col-sm-2 control-label">'+key+'</label>';
     	         			var div='<div class="form-group ">'+label+div2+'</div>';	
     	         			meg.append(div);
         				}	
     					
     				}else{
     					$("#countNumMsg").html('未知错误，请稍候再试<i class="fa fa-info-circle"></i>');
     				}
     			},
     			dataType : "json",
     		});
	});

	setMyActive(4,1,2); //设置激活页
});

function countNum(count,valid,inValid) {
	
        $("#countNumMsg").html("共计号码：<font color=\"red\">" + count + " </font>个" +
        		",有效号码：<font color=\"red\">" + valid + " </font>个" +
        		",无效号码：<font color=\"red\">" + inValid + " </font>个<i class=\"fa fa-info-circle\"></i>");
}

// 号码变动时的操作锁定提交按钮
function lockSubmitButton(){
	$("#submitButtonId").attr("disabled", true);
}

function submitOrder() {
	var terminalName = $("#terminalName").val();
	var phoneNo = $("#mobilenumbers").val();
	var orderType = "2";
	var scope = "nation";
	var type = "2";
	$.ajax({
		type : "get",
		url : basePath + 'order/webSubmit',
		data : {
			terminalName : terminalName,
			phoneNo : phoneNo,
			orderType : orderType,
			scope: scope,
			type:type
		},
		success : function(dt) {
			alert("提交成功"+dt.success+"个，提交失败"+dt.error+"个，");
		},
		dataType : 'json'
	});
}

